<template>
	<view>
		<!-- 最外层的容器 -->
		<view class="my-settle-container">
			<!-- 全选区域 -->
			<label class="radio">
				<radio color="#C00000" :checked="checked" @click="selectClick" /><text>全选</text>
			</label>
			<!-- 合计区域 -->
			<view class="amount-box">
				合计:<text class="amount">￥{{totalPrice}}</text>
			</view>
			<!-- 结算按钮 -->
			<view class="btn-settle" @click="settleAccounts">结算({{totalPrice}})</view>
		</view>
	</view>
</template>

<script>

	export default {
		name: "mySettle",
		props: {
			total: {
				type: Number,
				default: 0
			},
		},
		data() {
			return {
				checked: true,
				totalPrice: 0
			};
		},
		mounted() {
			this.totalPrice = this.$props.total
		},

		methods: {
			//全选
			selectClick() {
				this.checked = !this.checked
				this.$emit("selectClick", this.checked)
			},
			//结算
			settleAccounts() {
				this.$emit("settleAccounts")
			}
		},
		watch: {
			total() {
				this.totalPrice = this.$props.total
			}
		}
	}
</script>

<style lang="scss">
	.my-settle-container {
		position: fixed;
		bottom: 100rpx;
		left: 0;
		width: 100%;
		height: 100rpx;
		// 将背景色从 cyan 改为 white
		background-color: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-left: 10rpx;
		font-size: 28rpx;
		z-index: 99;

		.radio {
			display: flex;
			align-items: center;
		}

		.amount {
			color: #c00000;
		}

		.btn-settle {
			height: 100rpx;
			min-width: 200rpx;
			background-color: #c00000;
			color: white;
			line-height: 100rpx;
			text-align: center;
			padding: 0 20rpx;
		}
	}
</style>